package com.itheima.timeTask;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class AnnotationTimerTaskTests {

    //  5秒执行一次
    @Scheduled(fixedDelay = 5000)
    public void task1(){
        System.out.println("5秒执行一次"+ LocalDateTime.now());
    }

    // cron 表达式每周一凌晨3点执行
    @Scheduled(cron = "0 0 3 ? * MON")
    public void task2(){
        System.out.println("每周一凌晨3点执行"+ LocalDateTime.now());
    }

}
